//bench.js
const app = getApp()
var lanya = require("../../utils/BLELocker.js");
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js')

Page({
  data: {
    deviceId: 'DKF9070B5F6874',
    bleList: [],
    _Device: {},
    _WXServiceUUID: '',
    _WXWriteUUID: '',
  },
  // 体验版本功能 start
  onLoad: function (options) {
    let that = this;
    lbbService.getMechList({},function(res){
      that.setData({
        hospitalList: res,
        originHospitalList: res,
      })
    })
  },

  chooseHospital: function (e) {
    let index = e.currentTarget.dataset.index
    let hospitalId = this.data.hospitalList[index].lbmId
    let hospitalName = this.data.hospitalList[index].name
    wx.navigateTo({
      url: '/pages/pileVersion/pileVersion?hospitalId=' + hospitalId + '&hospitalName=' + hospitalName,
    })
  },
  inputHospital: function (e) {
    this.setData({
      inputHospital: e.detail.value
    });
    let searchName = this.data.inputHospital;
    let hospitals = [];
    let originHospitalList = this.data.originHospitalList;
    for (let i = 0; i < originHospitalList.length; i++) {
      if (originHospitalList[i].name.indexOf(searchName) != -1) {
        hospitals.push(originHospitalList[i]);
      }
    }
    if (this.data.inputHospital == '') {
      hospitals = this.data.originHospitalList;
    }
    this.setData({
      hospitalList: hospitals
    })
  },
  // 体验版本功能 end



  onReady: function () {
    // Do something when page ready.
  },
  onShow: function () {
    // Do something when page show.
  },
  onHide: function () {
    // Do something when page hide.
  },
  onUnload: function () {
    // Do something when page close.
  },
  onPullDownRefresh: function () {
    // Do something when pull down
  },

})